﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using log4net;
using TFXK.BLL;
using TFXK.Common;
using log4net;
using TFXK.Model;
using System.Data;

public partial class TravelDoc : System.Web.UI.Page
{
    private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
    private static readonly CategoryBLL bllCategory = new CategoryBLL();
    private static readonly NewsBLL bllNews = new NewsBLL();
    public Category model = new Category();
    int count = 0;
    string KeyCode = "lyxx";
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {

            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }
    }

    #region 分页绑定
    private void InitData(int PageIndex)
    {
        DataSet ds = new DataSet();
        if (Request.QueryString["KeyCode"] != null)
        {
            KeyCode = StringUtil.HtmlEncode(Request.QueryString["KeyCode"] + "");
        }
        if (string.IsNullOrEmpty(KeyCode))
        {
            KeyCode = "lyxx";
        }
        if (KeyCode.Equals("xxss"))
        {
            panlPubDoc.Visible = true;
        }
        SetImgNav(KeyCode);
        ds = bllNews.GetAllListByCodeNo(AspNetPager1.PageSize, PageIndex, KeyCode, "state='1'", out count);
        AspNetPager1.RecordCount = count;

        this.rptContent.DataSource = ds.Tables[0].DefaultView;
        this.rptContent.DataBind();
    }
    #endregion

    #region 分页控件加载
    protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
    {
        try
        {
            if (!Page.IsPostBack)
            {
                InitData(e.NewPageIndex);
            }
        }
        catch (Exception ex)
        {
            log.Error(ex.Message);
        }
    }
    #endregion

    public void SetImgNav(string code)
    {
        if (code.Equals("lyxx"))
        {
            imgNav.ImageUrl = "images/lyxx.jpg";
        }
        else if (code.Equals("lysx"))
        {
            imgNav.ImageUrl = "images/lysx.jpg";
        }
        else if (code.Equals("lygl"))
        {
            imgNav.ImageUrl = "images/lygl.jpg";
        }
        else if (code.Equals("lycjwt"))
        {
            imgNav.ImageUrl = "images/cjwt.jpg";
        }
        else if (code.Equals("xxss"))
        {
            imgNav.ImageUrl = "images/xxss.jpg";
        }
    }
}
